/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.kmcsoft.goldshop.currencyexchange.service.impl;

import com.kmcsoft.goldshop.model.exchange.CurrencyExchange;
import com.kmcsoft.goldshop.model.master.Currency;
import com.kmcsoft.goldshop.currencyexchange.service.RateSevice;
import com.kmcsoft.master.defaultservice.DefaultGenericService;
import java.util.Collection;

/**
 *
 * @author kmcsoft02
 */
public class JdoRateService extends DefaultGenericService implements RateSevice {

    public Collection<Currency> getCurrencies() {
        return getJdoTemplate().detachCopyAll(getJdoTemplate().find(Currency.class, "using==true"));
    }

    public CurrencyExchange getCurrencyExchangeById(Object id) {
        getPersistenceManager().getFetchPlan().addGroup("detach_CurrencyExchange_All");
        getPersistenceManager().getFetchPlan().addGroup("detach_CurrencyExchangeDetail_Currency");
        getPersistenceManager().getFetchPlan().setMaxFetchDepth(-1);
       return getJdoTemplate().detachCopy(getJdoTemplate().getObjectById(CurrencyExchange.class, id));
    }

    
    public String getBasicCurrencyCode() {
        return getBusinessInfo().getBankRate().getCurrency();
    }
}
